﻿using System;

namespace Pagination.Storage
{
    public class LevelProvider : ILevelProvider
    {
        private readonly Random random = new Random(Environment.TickCount);
        private const double Probability = 0.25;

        public int NewLevel(int maxLevel)
        {
            var level = 0;
            while (random.NextDouble() < Probability && level < maxLevel)
                ++level;
            return level;
        }
    }
}
